#导出数据

import pandas as pd
import pymysql


# 连接数据库
connect = pymysql.connect(host="localhost", user="root", password="hsb010811", database="618")
# 创建光标
cursor = connect.cursor()
# 编写SQL语句
query = "SELECT * FROM 员工表"
cursor.execute(query)

# 从查询结果中获取所有行
results = cursor.fetchall()

# 关闭数据库连接
cursor.close()
connect.close()

# 将查询结果转换为DataFrame
df = pd.DataFrame(results)

# 将数据导出到CSV文件
df.to_csv('output.csv', index=False)